Skip to content

fix(powershell): stop Out-Null swallowing the AVAILABLE_DOCS status lines - #3891

Open
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/ps-checkprereq-outnull
Open

fix(powershell): stop Out-Null swallowing the AVAILABLE_DOCS status lines#3891
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/ps-checkprereq-outnull

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

Problem

Test-FileExists and Test-DirHasFiles in scripts/powershell/common.ps1 do two things on the Success stream — they write the report line and return a bool:

function Test-FileExists {
    param([string]$Path, [string]$Description)
    if (Test-Path -Path $Path -PathType Leaf) {
        Write-Output "  [OK] $Description"
        return $true
    } else {
        Write-Output "  [FAIL] $Description"
        return $false
    }
}

check-prerequisites.ps1 piped the whole call to | Out-Null to throw away the boolean — which threw away the report line too.

Reproduction on current main (81bf741)

powershell.exe -NoProfile -File .specify/scripts/powershell/check-prerequisites.ps1 -IncludeTasks, in a project with specs/001-f/plan.md and specs/001-f/contracts/:

FEATURE_DIR:...\specs\001-f
AVAILABLE_DOCS:
=== line count: 2 ===

AVAILABLE_DOCS: is emitted with nothing under it. The bash and Python twins list all five documents for the same inputs, so the PowerShell variant silently returns less information — and any agent parsing the doc list sees none.

Fix

Drop only the boolean:

Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Where-Object { $_ -isnot [bool] }

Measured after the fix, same project plus research.md:

FEATURE_DIR:...\specs\001-f
AVAILABLE_DOCS:
  [OK] research.md
  [FAIL] data-model.md
  [FAIL] contracts/
  [FAIL] quickstart.md
  [FAIL] tasks.md
=== line count: 7 ===

No breaking change. JSON mode does not go through this path and is untouched. The booleans were already being discarded and are still discarded; the only difference is that the lines the helpers were writing now actually reach stdout. Exit codes unchanged.

The file stays ASCII-only — verified 0 non-ASCII bytes after the edit.

Verification

  • Fail-before / pass-after: the new test fails on unpatched source and passes with the fix. File: 1 failed → 12 passed, 8 skipped.
  • This is the first PowerShell text-mode test in this file — every existing PS test uses -Json, which is why the gap was never caught. It is gated on the file's existing HAS_PWSH or _WINDOWS_POWERSHELL guard.
  • Scoped regression: failure set identical to the clean-main baseline captured on 81bf741 (0 pre-existing in scope).
  • uvx ruff@0.15.0 check src tests → clean

Note this test file is also touched by my open #3785 and #3890, so expect a trivial append conflict depending on merge order — happy to rebase.


Written with assistance from Claude Code. Bug found, reproduced, and verified by me on current main with real powershell.exe.

@jawwad-ali
jawwad-ali requested a review from mnriem as a code owner July 31, 2026 07:58
…ines

Test-FileExists / Test-DirHasFiles report their line with Write-Output and
ALSO return $true/$false — both on the Success stream. The callers piped
the whole call to `| Out-Null` to discard the boolean, which discarded the
report line with it, so text mode printed the header and nothing under it:

  BEFORE (measured, powershell.exe -NoProfile -File ... -IncludeTasks):
    FEATURE_DIR:...\specs\001-f
    AVAILABLE_DOCS:
    (2 lines)

  AFTER:
    FEATURE_DIR:...\specs\001-f
    AVAILABLE_DOCS:
      [OK] research.md
      [FAIL] data-model.md
      [FAIL] contracts/
      [FAIL] quickstart.md
      [FAIL] tasks.md
    (7 lines)

The bash and Python twins both list every document under that header, so
the PowerShell variant silently returned less information for the same
inputs.

Filter out only the boolean, keeping the report lines. Adds the first
PowerShell text-mode test in this file (every existing PS test is -Json).
File stays ASCII-only (verified 0 non-ASCII bytes).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jawwad-ali
jawwad-ali force-pushed the fix/ps-checkprereq-outnull branch from 59f5e38 to 6e52eb5 Compare July 31, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant